﻿using System;
using System.Collections.Generic;
using System.Linq;

using Haushaltsbuch.Helpers;

using Ninject;
using Ninject.Extensions.Conventions;
using Ninject.Extensions.Conventions.Syntax;

namespace Haushaltsbuch.Extensions
{
    public static class NinjectExtensions
    {
        public static void BindExports(this IKernel kernel,
                                       Func<IFromSyntax, IIncludingNonePublicTypesSelectSyntax> from)
        {
            kernel.Bind(x => from(x).IncludingNonePublicTypes()
                                    .SelectAllClasses()
                                    .WithAttribute<ExportAttribute>()
                                    .BindWith<ExportBindingGenerator>());
        }
    }
}